Skip to main content

Linters

Linters are tools for checking consistency and quality of code, but they can be used on every type of content. They enforce a consistent style for writing content, making it easier for content creators to read and maintain. There are different types of linters, depending on the type of content. For example, a linting tool for code is different from a linting tool for text.

Examples

  • Super-Linter is a combination of various linters that can be used locally or in CI/CD pipelines.
  • markdownlint is a linter for Markdown files.
  • spellcheck is a linter for text for check spelling.

All of these linters are available in the actions repository.

Rules

Every linter has a set of default rules that it uses to check the content. Some rules can be configured to ignore some errors that are not relevant to the project. For example, markdownlint can ignore some errors that are not relevant to Markdown files using custom rules. We are currently using some custom rules for Markdown files that can be found in the actions repository.

Usage

Locally

There are multiples ways to run linters locally.

Super-Linter can be run locally inside a Docker container using this script. The script expects two arguments, the path to the codebase and the path to the linting rules. Linting rules are used because sometimes the linter might be too strict. Configuring these rules can ignore some errors that are not relevant for the project. The linting rules that we are currently using and recommending are inside the actions repository.

Another way of using linters locally is to check supported linters by super-linter and try to run them locally. markdownlint is a good example. It's the linter used by super-linter for Markdown files.

Of course, for some linters you can find a web solution that can run the linter without installing it locally. For example, on this website you can use markdownlint by copy-pasting the content of the file you want to check.

Continuous Integration and Continuous Delivery

The most common way to use linters is in CI/CD pipelines. By default, our template repository is already configured to use super-linter for linting on every pull request. By forking it, you will already have this configuration.

Otherwise, if you want to use it without forking or if you want to modify it, you should be aware of the actions repository. In this repository we store the configuration files for multiple linters used by super-linter.